/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once
#include "Component.h"
#include "../render/Animation.h"

namespace gui {
/**
==========================
A gui button
==========================
*/
class MButton : public gui::Component
{
public:
    MButton(const gui::Component* c) : gui::Component(c) 
    { m_normalAnim.Set( 1, 1, 1, 1); m_hoverAnim.Set(1,1,1,1); 
      m_bgImageInit = m_hvImageInit = false; 
    };

    /** Add Functions to actions */
    void SetOnClick( const std::string &s ) { m_onClick = s; };
    void OnClick();

    /** Set/Get Text */
    void SetText( const std::string &s ) { m_text = s; };
    std::string GetText() { return m_text; };

    /** Set background Image */
    void SetBackgroundImage( Image image, int fps, int amt, int row, int col );
    /** Set background Image */
    void SetHoverImage( Image image, int fps, int amt, int row, int col );
    
    /** Update this component */
    virtual void Update( float dt );
    virtual void Render( IRender* r );
    /** Handle input */
    virtual bool HandleInput();

private:
    /** Hover Effect */
    bool            m_Hover;

    Image           m_backgroundImage;
    Image           m_hoverImage;
    bool            m_bgImageInit;
    bool            m_hvImageInit;

    Animation       m_normalAnim;
    Animation       m_hoverAnim;
    // script to activate when clicked
    std::string     m_onClick;

    // text
    std::string     m_text;
public:
    virtual ~MButton(void) {};

};

};